﻿namespace IOPvsOOP.Polymorphism.IF
{
    public enum ClusterEnum
    {
        Director,
        Executive,
        Manager,
        Leader,
        OfficeWorker
    }

    public class EmployeeEnum
    {
        public string Name { get; set; }
        public string Last { get; set; }
        public string Number { get; set; } 
        public ClusterEnum Cluster { get; set; }
        public int Days { get; set; }
    }

    public class SalaryCalculatorEnum
    {
        public double Calculate(EmployeeEnum employeeEnum)
        {
            switch (employeeEnum.Cluster)
            {
                case ClusterEnum.Director:
                    return employeeEnum.Days * 100;
                case ClusterEnum.Executive: 
                    return employeeEnum.Days * 80;
                case ClusterEnum.Manager:
                    return employeeEnum.Days * 60;
                case ClusterEnum.Leader:
                    return employeeEnum.Days * 45;
                case ClusterEnum.OfficeWorker:
                    return employeeEnum.Days * 23;
            }
            return -1;
        }
    }

    public class SalaryBenefitCalculatorEnum
    {
        private readonly SalaryCalculatorEnum inner;

        public SalaryBenefitCalculatorEnum(SalaryCalculatorEnum inner)
        {
            this.inner = inner;
        }

        public double Calculate(EmployeeEnum employeeEnum)
        {
            var result = inner.Calculate(employeeEnum);

            switch (employeeEnum.Cluster)
            {
                case ClusterEnum.Director:
                    return Benefit(result, 3);
                case ClusterEnum.Executive:
                    return Benefit(result, 5);
                case ClusterEnum.Manager:
                    return Benefit(result, 5);
                case ClusterEnum.Leader:
                    return Benefit(result, 10);
                case ClusterEnum.OfficeWorker:
                    return Benefit(result, 20);
            }
            return -1;
        }

        private static double Benefit(double result, int ratio)
        {
            return result + result / 100 * ratio;
        }
    }
}